package projetolp2.GraphicInterface;

import javax.swing.*;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;


public class MenuPrincipal extends MealPoints implements ActionListener{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JPanel painel1 = new JPanel(new GridLayout(0,1));
	private JPanel painel2 = new JPanel(new GridLayout(0,1));
	private JPanel painel3 = new JPanel(new GridLayout(0,1));
	private JPanel painel4 = new JPanel(new GridLayout(0,1));
	private JPanel painel5 = new JPanel(new GridLayout(0,1));
	private JPanel panelMenu = new JPanel(new BorderLayout());
	private JButton CADASTRAOPINIOES = new JButton(NomeBotoes.values()[idioma(IDIOMAPROGRAMA )].getCadastraOpinioes());
	private JButton RANKINGGERAL = new JButton(NomeBotoes.values()[idioma(IDIOMAPROGRAMA )].getRankingGeral());
	private JButton VISUALIZARPERFIS = new JButton(NomeBotoes.values()[idioma(IDIOMAPROGRAMA )].getVisualizarOpinioes());
	private JButton SUGESTOES = new JButton(NomeBotoes.values()[idioma(IDIOMAPROGRAMA )].getSugestoes());
	private JButton CONFIGURACOES = new JButton(NomeBotoes.values()[idioma(IDIOMAPROGRAMA )].getConfiguracoes());
	final JLabel label = new JLabel("Meal points");
	private JPanel panelFinal = new JPanel(new GridLayout(0,1));
	
	public MenuPrincipal(){

	}
	private void ajudaDeBotoes(){
		CADASTRAOPINIOES.setToolTipText("Cadastra um novo usu�rio com suas opinioes sobre os estabelecimentos");
		RANKINGGERAL.setToolTipText("Classifica��o dos estabelecimentos");
		VISUALIZARPERFIS.setToolTipText("Visualiza as opinioes dos usu�rios");
		SUGESTOES.setToolTipText("Sugest�es de onde voc� pode comer");
		CONFIGURACOES.setToolTipText("Alterar configura��es padrao");
	}
	
	public void actionPerformed(ActionEvent e){
		if(e.getSource() == CADASTRAOPINIOES){
			removerAdicionar(menu, cadastrar);
		}
		else if(e.getSource() == RANKINGGERAL){
			removerAdicionar(menu, rank);
		}
		else if(e.getSource() == VISUALIZARPERFIS){
			removerAdicionar(menu, visualizarOpinioes);
		}
		else if(e.getSource() == SUGESTOES){
			removerAdicionar(menu, sugestoes);			
		}
		else if(e.getSource() == CONFIGURACOES){
			removerAdicionar(menu, configuracoes);			
		}
	}
	private void createComponents() {
        
		ajudaDeBotoes();
		CADASTRAOPINIOES.setMnemonic(KeyEvent.VK_I);
		CADASTRAOPINIOES.addActionListener(this);
        label.setLabelFor(CADASTRAOPINIOES);
        
        RANKINGGERAL.setMnemonic(KeyEvent.VK_I);
        RANKINGGERAL.addActionListener(this);
        label.setLabelFor(RANKINGGERAL);
        
        VISUALIZARPERFIS.setMnemonic(KeyEvent.VK_I);
        VISUALIZARPERFIS.addActionListener(this);
        label.setLabelFor(VISUALIZARPERFIS);
        
        SUGESTOES.setMnemonic(KeyEvent.VK_I);
        SUGESTOES.addActionListener(this);
        label.setLabelFor(SUGESTOES);
        
        CONFIGURACOES.setMnemonic(KeyEvent.VK_I);
        CONFIGURACOES.addActionListener(this);
        label.setLabelFor(CONFIGURACOES);
        painel1.add(VISUALIZARPERFIS);
        painel2.add(CADASTRAOPINIOES);
        painel3.add(SUGESTOES);
        painel4.add(RANKINGGERAL);
        painel5.add(CONFIGURACOES);

        painel1.setBorder(BorderFactory.createEmptyBorder(
                30, //top
                10, //left
                30, //bottom
                10) //right
                );
        painel2.setBorder(BorderFactory.createEmptyBorder(
                30, //top
                10, //left
                30, //bottom
                10) //right
                );
        painel3.setBorder(BorderFactory.createEmptyBorder(
                30, //top
                10, //left
                30, //bottom
                10) //right
                );
        painel4.setBorder(BorderFactory.createEmptyBorder(
                30, //top
                10, //left
                30, //bottom
                10) //right
                );
        painel5.setBorder(BorderFactory.createEmptyBorder(
                30, //top
                10, //left
                30, //bottom
                10) //right
                );
        panelFinal.add(painel1);
        panelFinal.add(painel2);
        panelFinal.add(painel3);
        panelFinal.add(painel4);
        panelFinal.add(painel5);
        panelMenu.add(panelFinal, BorderLayout.EAST);
    }
	public Component panel(){
		createComponents();
		panelMenu.setVisible(true);
		
		
		return panelMenu;
	}

}
